import { observable, action,makeObservable } from 'mobx';
import moment from "moment";
import { currentUser } from "@/services/auth";
import GlobalFunctions from '@/store/globalFunctions';

class EmployeeModel {
    @observable id= 0;//
    @observable bill_date=moment();//--申请日期
    @observable code= "";//----职员编码
    @observable name= "";//--职员名称
    @observable sex= "男";//性别
    @observable mobile= "";//手机号
    @observable contacts= "";//联系人
    @observable contactsmobile= "";//联系方式
    @observable idcard= "";//身份证号
    @observable wechat="";
    @observable major= [];//毕业专业
    @observable certificate= [];//证书
    @observable location= "";//地区
    @observable socialsecurity= 0;//社保情况（无，有）
    @observable area= "";//社保地区
    @observable threeperson= "";//三类项目
    @observable biddingexit= "";//招标出场（是否)
    @observable certificatestatus= "";//证书状态 不限，初始注册，转注册
    @observable price= 0;//预计金额
    @observable frontmoney= 0;//定金
    @observable periodunit = "年";//期限单位
    @observable periods = 1;//期限
    @observable informationfee = 0;//信息费
    @observable message = "";//--纪录事项
    @observable contracttype= "";//签约类型
    @observable bytstatus= "洽谈中";
    @observable signingtime= null;//签约时间
    @observable expirationtime= null;//到期时间
    @observable status= 0;//--状态
    @observable maintainer= currentUser.id;//--维护人
    @observable signatory= "";//--签约人
    @observable userid= currentUser.id;//--操作员ID
    @observable orgunitid= currentUser.orgunit_id;
    @observable signamount= 0;
    @observable excelin= 0;
    @observable contractcode= "";
    @observable accountname= "";//户名
    @observable accountcode= "";//账户
    @observable accountbank = "";//开户行
    @observable schooled = "";
    @observable openshow = 0;
    @observable openseapool=0;
    @observable ifproject =0;
    @observable certificate1 = [];
    @observable certificate2 = [];
    @observable certificate3 = [];
    @observable certificate4 = [];
    @observable certificate5 = [];
    @observable certificate6 = [];
    @observable certificatelen = 1;
    //===================   
    @observable isnew= true;
    @observable isedit=true;
    @observable allow_col=[];
    @observable colcontrol=false;

    constructor(id,openseapool,ifproject) {
        this.id=id;
        this.openseapool=openseapool;
        this.ifproject=ifproject;
        this.openshow = openseapool===0 ? ifproject:1;
        
        makeObservable(this);
    }
    @action setCode(code) {
        this.code = code;
    }
    @action setName(name) {
        this.name = name;
    }
    @action setBilledit(item) {
        this.isedit = item.edit;
        this.allow_col = item.allow_col;
        this.colcontrol = item.colcontrol;
    }
    @action setBill_date(bill_date) {
        this.bill_date = bill_date;
    }
    @action setSex(sex) {
        this.sex = sex;
    }
    @action setMobile(mobile) {
        this.mobile = mobile;
    }
    @action setContacts(contacts) {
        this.contacts = contacts;
    }
    @action setContactsmobile(contactsmobile) {
        this.contactsmobile = contactsmobile;
    }
    @action setIdcard(idcard) {
        this.idcard = idcard;
    }
    @action setWechat(wechat) {
        this.wechat = wechat;
    }
    @action setMajor(major) {
        this.major = major;
    }
    @action setCertificate(certificate) {
        this.certificate = certificate;
    }
    @action setLocation(location) {
        this.location = location;
    }
    @action setSocialsecurity(socialsecurity) {
        this.socialsecurity = socialsecurity;
    }
    @action setArea(area) {
        this.area = area;
    }
    @action setThreeperson(threeperson) {
        this.threeperson = threeperson;
    }
    @action setBiddingexit(biddingexit) {
        this.biddingexit = biddingexit;
    }
    @action setCertificatestatus(certificatestatus) {
        this.certificatestatus = certificatestatus;
    }
    @action setPrice(price) {
        this.price = price;
    }
    @action setFrontmoney(frontmoney) {
        this.frontmoney = frontmoney;
    }
    @action setPeriodunit(periodunit) {
        this.periodunit = periodunit;
    }
    @action setPeriods(periods) {
        this.periods = periods;
    }
    @action setInformationfee(informationfee) {
        this.informationfee = informationfee;
    }
    @action setMessage(message) {
        this.message = message;
    }
    @action setContracttype(contracttype) {
        this.contracttype = contracttype;
    }
    @action setBytstatus(bytstatus) {
        this.bytstatus = bytstatus;
    }
    @action setSigningtime(signingtime) {
        this.signingtime = signingtime;
    }
    @action setExpirationtime(expirationtime) {
        this.expirationtime = expirationtime;
    }
    @action setStatus(status) {
        this.status = status;
    }
    @action setMaintainer(maintainer) {
        this.maintainer = maintainer;
    }
    @action setSignatory(signatory) {
        this.signatory = signatory;
    }
    @action setUserid(userid) {
        this.userid = userid;
    }
    @action setOrgunitid(orgunitid) {
        this.orgunitid = orgunitid;
    }
    @action setSignamount(signamount) {
        this.signamount = signamount;
    }
    @action setExcelin(excelin) {
        this.excelin = excelin;
    }
    @action setContractcode(contractcode) {
        this.contractcode = contractcode;
    }
    @action setAccountname(accountname) {
        this.accountname = accountname;
    }
    @action setAccountcode(accountcode) {
        this.accountcode = accountcode;
    }
    @action setAccountbank(accountbank) {
        this.accountbank = accountbank;
    }
    @action setSchooled(schooled) {
        this.schooled = schooled;
    }
    @action setOpenshow(openshow) {
        this.openshow = openshow;
    }
    @action setCertificate1(certificate1) {
        this.certificate1 = certificate1;
    }
    @action setCertificate2(certificate2) {
        this.certificate2 = certificate2;
    }
    @action setCertificate3(certificate3) {
        this.certificate3 = certificate3;
    }
    @action setCertificate4(certificate4) {
        this.certificate4 = certificate4;
    }
    @action setCertificate5(certificate5) {
        this.certificate5 = certificate5;
    }
    @action setCertificate6(certificate6) {
        this.certificate6 = certificate6;
    }
    @action setCertificatelen(certificatelen) {
        this.certificatelen = certificatelen;
    }

    static fromJS(obj) {
        let m =  new EmployeeModel(obj.id,obj.openseapool,0);
        //m.id= obj.id ;
        m.bill_date= moment(obj.bill_date);//--申请日期
        m.code= obj.code ;//--编码
        m.name= obj.name;//名称
        m.sex= obj.sex;//性别
        m.mobile=  obj.mobile;//手机号
        m.contacts=  obj.contacts;//联系人
        m.contactsmobile=  obj.contactsmobile;//联系方式
        m.idcard= obj.idcard;//身份证号
        m.wechat= obj.wechat;
        m.major=  obj.major;//毕业专业
        m.certificate=  obj.certificate;//证书
        m.location=  obj.location;//地区
        m.socialsecurity=  obj.socialsecurity;//社保情况（无，有）
        m.area=  obj.area;//社保地区
        m.threeperson=  obj.threeperson;//三类项目
        m.biddingexit=  obj.biddingexit;//招标出场（是否)
        m.certificatestatus=  obj.certificatestatus;//证书状态 不限，初始注册，转注册
        m.price=  obj.price;//预计金额
        m.frontmoney=  obj.frontmoney;//定金
        m.periodunit =  obj.periodunit;//期限单位
        m.periods =  obj.periods;//期限
        m.informationfee =  obj.informationfee;//信息费
        m.message =  obj.message;//--纪录事项
        m.contracttype=  obj.contracttype;//签约类型
        m.bytstatus=  obj.bytstatus;
        m.signingtime = obj.signingtime ? (GlobalFunctions.isEmptyobj(obj.signingtime) ? null : moment(obj.signingtime)) : null;//签约时间
        m.expirationtime = obj.expirationtime ? (GlobalFunctions.isEmptyobj(obj.expirationtime) ? null : moment(obj.expirationtime)) : null;//到期时间
        m.status=  obj.status;//--状态
        m.maintainer=  obj.maintainer;//--维护人
        m.signatory= obj.signatory;//--签约人
        m.userid=  obj.userid;//--操作员ID
        m.orgunitid=  obj.orgunitid;
        m.signamount=  obj.signamount;
        m.excelin=  obj.excelin;
        m.contractcode=  obj.contractcode;
        m.accountname=  obj.accountname;
        m.accountcode= obj.accountcode;
        m.accountbank =  obj.accountbank;
        m.schooled =  obj.schooled;
        m.openshow = obj.openshow;

        if (obj.certificate.length > 0) {
            m.certificate1 = obj.certificate[0].split('-')
            m.certificatelen = obj.certificate.length;
        }
        if (obj.certificate.length > 1) {
            m.certificate2 = obj.certificate[1].split('-')
        }
        if (obj.certificate.length > 2) {
            m.certificate3 = obj.certificate[2].split('-')
        }
        if (obj.certificate.length > 3) {
            m.certificate4 = obj.certificate[3].split('-')
        }
        if (obj.certificate.length > 4) {
            m.certificate5 = obj.certificate[4].split('-')
        }
        if (obj.certificate.length > 5) {
            m.certificate6 = obj.certificate[5].split('-')
        }
        m.isnew= false;
        return m;
    }
}

export default EmployeeModel;